<%@page import="com.javabean.BookBean"%>
<%@page import="com.sql.Book"%>
<%@page import="com.sql.User"%>
<%@page import="com.javabean.BorrowBean"%>
<%@page import="com.javabean.UserBean"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge;charset=UTF-8">
	
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta name="description" content="Xenon Boostrap Admin Panel" />
	<meta name="author" content="" />
	
	<title>图书管理系统 - 借阅</title>

	<!-- <link rel="stylesheet" href="http://fonts.useso.com/css?family=Arimo:400,700,400italic"> -->
	<link rel="stylesheet" href="assets/css/fonts/linecons/css/linecons.css">
	<link rel="stylesheet" href="assets/css/fonts/fontawesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="assets/css/bootstrap.css">
	<link rel="stylesheet" href="assets/css/xenon-core.css">
	<link rel="stylesheet" href="assets/css/xenon-forms.css">
	<link rel="stylesheet" href="assets/css/xenon-components.css">
	<link rel="stylesheet" href="assets/css/xenon-skins.css">
	<link rel="stylesheet" href="assets/css/custom.css">

	<script src="assets/js/jquery-1.11.1.min.js"></script>

	<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!--[if lt IE 9]>
		<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
</head>
<body class="page-body">
	
	<% 
		String iduser = (String)session.getAttribute("iduser");
		String level = (String)session.getAttribute("level");
		String username = (String)session.getAttribute("username");
		
		List blist = (List) request.getAttribute("blist"); 
		String idbook = "idbook";
	%>
<%-- 	<table border="1">
		<thead>
			<tr>
				<th>用户名</th>
				<th>书名</th>
				<th>借书日期</th>
				<th>应还日期</th>
				<th>操作</th>
			</tr>
		</thead>
		<%
			for(int i = 0; i < blist.size(); i++) {
				BorrowBean bb = (BorrowBean) blist.get(i);
				User user = new User();
				List userlist = user.getOnefo(bb.getIduser()); 
				UserBean uBean= (UserBean) userlist.get(0);
				Book book = new Book();
				List booklist = book.searchBook(idbook,bb.getIdbook());
				BookBean bBean = (BookBean) booklist.get(0);
		%>
		<tbody>
			<tr>
				<td><%=uBean.getUsername() %></td>
				<td><%=bBean.getBookname() %></td>
				<td><%=bb.getBtime() %></td>
				<td><%=bb.getRtime() %></td>
				<td>
					<div>
						<a href="doReturn?id=<%=bb.getId() %>&&book=<%=bb.getIdbook()%>">归还</a>
						<button id="update" onclick="{ location.href='borrowUpdate'}" class="">修改 </button>
						
					</div>
				</td>
			</tr>
		</tbody>
		<%} %>
		
	</table> --%>
	
	<div class="settings-pane">
			
		<a href="#" data-toggle="settings-pane" data-animate="true">
			&times;
		</a>
		
	</div>
	
	<div class="page-container"><!-- add class "sidebar-collapsed" to close sidebar by default, "chat-visible" to make chat appear always -->
			
		<!-- Add "fixed" class to make the sidebar fixed always to the browser viewport. -->
		<!-- Adding class "toggle-others" will keep only one menu item open at a time. -->
		<!-- Adding class "collapsed" collapse sidebar root elements and show only icons. -->
		<div class="sidebar-menu toggle-others fixed">
			
			<div class="sidebar-menu-inner">	
				
				<header class="logo-env">
					
					<!-- logo -->
					<div class="logo">
						<a href="" class="logo-expanded">
							<img src="assets/images/logo@2x.png" width="80" alt="" />
						</a>
						
						<a href="" class="logo-collapsed">
							<img src="assets/images/logo-collapsed@2x.png" width="40" alt="" />
						</a>
					</div>
									
				</header>
						
				
						
				<%
					if(level.equals("3")){
				%>
						
				<ul id="main-menu" class="main-menu">
					<!-- add class "multiple-expanded" to allow multiple submenus to open -->
					<!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
					<li>
						<a href="home.jsp">
							<i class="linecons-star"></i>
							<span class="title">主页</span>
						</a>
					</li>
					<br/><br/>
					<li>
						<a href="myBorrow">
							<i class="linecons-star"></i>
							<span class="title">我的借阅</span>
						</a>
					</li>
					<li>
						<a href="managebook?page=<%=(int)1%>">
							<i class="linecons-star"></i>
							<span class="title">图书列表</span>
						</a>
					</li>
					<li>
						<a href="userInfo?iduser=<%=iduser%>">
							<i class="linecons-star"></i>
							<span class="title">我的资料</span>
						</a>
					</li>
				</ul>
				<%}
					else{
				%>
				<ul id="main-menu" class="main-menu">
					<!-- add class "multiple-expanded" to allow multiple submenus to open -->
					<!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
					<li>
						<a href="home.jsp">
							<i class="linecons-star"></i>
							<span class="title">主页</span>
						</a>
					</li>
					<br/><br/>
					<li>
						<a href="myBorrow">
							<i class="linecons-star"></i>
							<span class="title">借阅管理</span>
						</a>
					</li>
					<li>
						<a href="managebook?page=<%=(int)1%>">
							<i class="linecons-star"></i>
							<span class="title">图书列表</span>
						</a>
					</li>
					<li>
						<a href="manageuser">
							<i class="linecons-star"></i>
							<span class="title">用户管理</span>
						</a>
					</li>
					<li>
						<a href="userInfo?iduser=<%=iduser%>">
							<i class="linecons-star"></i>
							<span class="title">我的资料</span>
						</a>
					</li>
				</ul>
				<%} %>
						
			</div>
			
		</div>
		<div class="main-content">
					
			<!-- User Info, Notifications and Menu Bar -->
			<nav class="navbar user-info-navbar" role="navigation">
				
				<!-- Left links for user info navbar -->
				<ul class="user-info-menu left-links list-inline list-unstyled">
					
					<li class="hidden-sm hidden-xs">
						<a href="#" data-toggle="sidebar">
							<i class="fa-bars"></i>
						</a>
					</li>
					
				</ul>
				
				
				<!-- Right links for user info navbar -->
				<ul class="user-info-menu right-links list-inline list-unstyled">
					
					<li class="dropdown user-profile">
						<a href="#" data-toggle="dropdown">
							<img src="assets/images/user-4.png" alt="user-image" class="img-circle img-inline userpic-32" width="28" />
							<span>
								 <%=username %>
								<i class="fa-angle-down"></i>
							</span>
						</a>
						
						<ul class="dropdown-menu user-profile-menu list-unstyled">
							<li>
								<a href="userInfo?iduser=<%=iduser%>">
									<i class="fa-edit"></i>
									个人资料
								</a>
							</li>
							<li>
								<a href="#settings">
									<i class="fa-wrench"></i>
									修改密码
								</a>
							</li>
							<li class="last">
								<a href="login.html">
									<i class="fa-lock"></i>
									退出
								</a>
							</li>
						</ul>
					</li>
					
					
				</ul>
				
			</nav>
			<div class="page-title">
				
				<div class="title-env">
					<h1 class="title">借阅记录</h1>
				</div>
				
					<div class="breadcrumb-env">
					
								<ol class="breadcrumb bc-1">
									<li>
										<a href="home.jsp"><i class="fa-home"></i>主页</a>
									</li>
									<li class="active">
										
										<strong>我的借阅</strong>
									</li>
								</ol>
								
				</div>
					
			</div>
			<!-- Table Styles -->
			<div class="row">
				<div class="col-md-12">
				
					<div class="panel panel-default">
						
						<div class="panel-body panel-border">
							
							<div class="row">
								<strong>借阅记录</strong>	
								<%
									if(level.equals("3")){
										
									}
									else{
								%>
								<div style="float:right">
									<form action="ubook" method="post">
										<div><input type="text" name = "iduser" /><input type="submit" value="搜索" class="btn btn-success btn-sm"/></div>
									</form>
								</div>
								<%} %>
								<table class="table table-bordered table-striped">
									<thead>
										<tr>
											<th>用户名</th>
											<th>书名</th>
											<th>借书日期</th>
											<th>归还日期</th>
											<th>操作</th>
										</tr>
									</thead>
									<%
										int x=1;
										for(int i = 0; i < blist.size(); i++) {
											BorrowBean bb = (BorrowBean) blist.get(i);
											User user = new User();
											List userlist = user.getOnefo(bb.getIduser()); 
											UserBean uBean= (UserBean) userlist.get(0);
											Book book = new Book();
											
											List booklist = book.searchBook(idbook,bb.getIdbook(),x);
											BookBean bBean = (BookBean) booklist.get(0);
									%>
									
									<tbody>
										<tr>
											<td><%=uBean.getUsername() %></td>
											<td><%=bBean.getBookname() %></td>
											<td><%=bb.getBtime() %></td>
											<td><%=bb.getRtime() %></td>
											<td>
												<div>
													<button id="doReturn" onclick="{ location.href='doReturn?id=<%=bb.getId() %>&&book=<%=bb.getIdbook()%>'}" class="">归还 </button>
												</div>
											</td>
										</tr>
									</tbody>
									<%} %>
								</table>
								<div>
									
								</div>
							</div>
							
						</div>
							
					</div>
					
				</div>
			</div>
			
			
			<footer class="main-footer sticky footer-type-1">
				
				<div class="footer-inner">
				
					<!-- Add your copyright text here -->
					<div class="footer-text">
						&copy; 2017 
						<strong>Our</strong> 
						 <a href="#" target="_blank" title="管理系统">图书管理系统</a> - Collect from <a href="#" title="网页模板" target="_blank">网页模板</a>
					</div>
					
					
					<!-- Go to Top Link, just add rel="go-top" to any link to add this functionality -->
					<div class="go-up">
					
						<a href="#" rel="go-top">
							<i class="fa-angle-up"></i>
						</a>
						
					</div>
					
				</div>
				
			</footer>
		</div>
		
	</div>
	
	
	



	<!-- Bottom Scripts -->
	<script src="assets/js/bootstrap.min.js"></script>
	<script src="assets/js/TweenMax.min.js"></script>
	<script src="assets/js/resizeable.js"></script>
	<script src="assets/js/joinable.js"></script>
	<script src="assets/js/xenon-api.js"></script>
	<script src="assets/js/xenon-toggles.js"></script>


	<!-- JavaScripts initializations and stuff -->
	<script src="assets/js/xenon-custom.js"></script>
</body>
</html>